﻿namespace OboutInc
{
    using System;
    using System.Collections;
    using System.ComponentModel;

    [TypeConverter(typeof(CallbackCollectionConverter))]
    public class CallbackCollection
    {
        private ICollection _collection;
        private int _count;
        private bool _isAssociative;

        public CallbackCollection(bool associative)
        {
            this._isAssociative = associative;
            if (associative)
            {
                this._collection = new Hashtable();
            }
            else
            {
                this._collection = new ArrayList();
            }
        }

        public object Add(object name, object value)
        {
            object obj2 = null;
            if (this._isAssociative)
            {
                ((Hashtable) this._collection).Add(name, value);
            }
            else
            {
                obj2 = ((ArrayList) this._collection).Add(value);
            }
            this._count++;
            return obj2;
        }

        public object Get(object index)
        {
            if (this._isAssociative)
            {
                return ((Hashtable) this._collection)[index];
            }
            return ((ArrayList) this._collection)[(int) index];
        }

        public IEnumerator GetEnumerator()
        {
            if (this._isAssociative)
            {
                return ((Hashtable) this._collection).GetEnumerator();
            }
            return ((ArrayList) this._collection).GetEnumerator();
        }

        public int Count
        {
            get
            {
                return this._count;
            }
        }

        public bool IsAssociative
        {
            get
            {
                return this._isAssociative;
            }
        }
    }
}

